/*    */ package com.engine;
/*    */ 
/*    */ import com.engines.DBEngine;
/*    */ import java.io.File;
/*    */ import java.io.PrintStream;
/*    */ import java.util.Map;
/*    */ import net.sf.jasperreports.engine.JRException;
/*    */ import net.sf.jasperreports.engine.JasperCompileManager;
/*    */ import net.sf.jasperreports.engine.JasperFillManager;
/*    */ import net.sf.jasperreports.engine.JasperPrint;
/*    */ import net.sf.jasperreports.engine.util.JRLoader;
/*    */ import net.sf.jasperreports.engine.util.JRXmlUtils;
/*    */ import net.sf.jasperreports.view.JasperViewer;
/*    */ import org.w3c.dom.Document;
/*    */ 
/*    */ public class Print
/*    */ {
/*    */   DBEngine db;
/*    */ 
/*    */   public Print()
/*    */   {
/* 23 */     this.db = new DBEngine();
/*    */   }
/*    */ 
/*    */   public boolean generateReport(String title, String rptName, Map<String, String> parameters)
/*    */   {
/*    */     try
/*    */     {
/* 31 */       JasperCompileManager.compileReportToFile(rptName + ".jrxml");
/* 32 */       JasperFillManager.fillReportToFile(rptName + ".jasper", parameters, this.db.getConnection());
/*    */ 
/* 34 */       File sourceFile = new File(rptName + ".jrprint");
/* 35 */       JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);
/* 36 */       JasperViewer jv = new JasperViewer(jasperPrint, false);
/* 37 */       jv.setAlwaysOnTop(true);
/* 38 */       jv.setTitle(title);
/*    */ 
/* 40 */       jv.setVisible(true);
/* 41 */       return true;
/*    */     }
/*    */     catch (JRException jre)
/*    */     {
/* 45 */       String connectMsg = "Could not create the report " + jre.getMessage() + " " + jre.getLocalizedMessage();
/* 46 */       System.out.println(connectMsg);
/* 47 */       return false;
/*    */     }
/*    */     catch (Exception e)
/*    */     {
/* 51 */       String connectMsg = "Could not create the report " + e.getMessage() + " " + e.getLocalizedMessage();
/* 52 */       System.out.println(connectMsg);
/* 53 */     }return false;
/*    */   }
/*    */ 
/*    */   public boolean generateReportXml(String title, String rptName, Map parameters, String xmldata)
/*    */   {
/*    */     try
/*    */     {
/* 61 */       Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream(xmldata));
/* 62 */       parameters.put("XML_DATA_DOCUMENT", document);
/* 63 */       parameters.put("XML_DATE_PATTERN", "yyyy-MM-dd");
/*    */ 
/* 65 */       JasperCompileManager.compileReportToFile(rptName + ".jrxml");
/* 66 */       JasperFillManager.fillReportToFile(rptName + ".jasper", parameters);
/*    */ 
/* 68 */       File sourceFile = new File(rptName + ".jrprint");
/* 69 */       JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);
/* 70 */       JasperViewer jv = new JasperViewer(jasperPrint, false);
/* 71 */       jv.setAlwaysOnTop(true);
/* 72 */       jv.setTitle(title);
/*    */ 
/* 74 */       jv.setVisible(true);
/* 75 */       jv.setAlwaysOnTop(false);
/* 76 */       return true;
/*    */     }
/*    */     catch (JRException jre)
/*    */     {
/* 80 */       String connectMsg = "Could not create the report " + jre.getMessage() + " " + jre.getLocalizedMessage();
/* 81 */       System.out.println(connectMsg);
/* 82 */       return false;
/*    */     }
/*    */     catch (Exception e)
/*    */     {
/* 86 */       String connectMsg = "Could not create the report " + e.getMessage() + " " + e.getLocalizedMessage();
/* 87 */       System.out.println(connectMsg);
/* 88 */     }return false;
/*    */   }
/*    */ }

/* Location:           F:\16 2\SQ.jar
 * Qualified Name:     com.engine.Print
 * JD-Core Version:    0.6.0
 */